<?php

/**
 * @author Do Van Tien
 * @copyright 2013
 */

    date_default_timezone_set('Asia/Ho_Chi_Minh');
    header('Content-Type: text/html; charset=utf-8');
    set_time_limit(0);
    
    $url = 'http://115.146.121.82:9092/get_user_info_by_id';
    $clientKey = '2621fafbb8b403cd1633de2e6a9cb844';
    $user_id = '806893922674448,766986143352513,264960210373948,b100001628316202,b100001649019985,b100000655315330,b100000677058976';
    
    $postData = array(
          'user_id' => $user_id,
          'signature' => md5($clientKey)
        );
        
    $fields = '';
    foreach($postData as $key => $value) { 
        $fields .= $key . '=' . $value . '&'; 
    }
    rtrim($fields, '&');
    
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: text/plain'));
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $fields);
    $result = curl_exec($curl);
    curl_close($curl);
    
    $result = json_decode($result);
    if(isset($result->error_code)){
        echo 'Error: '.$result->error_message;
        exit;
    }
    pr($result);
    
    function pr($data, $die = true)
    {
        $numargs = func_num_args();
        $data = func_get_args();
        if($numargs == 1){
            $data = $data[0];
        }

        $trace = debug_backtrace();
        $caller = array_shift($trace);
        echo '<pre>';
        echo "called by [" . $caller['file'] . "] line: " . $caller['line'] . "\n";
        print_r($data);
        if ($die) {
            die();
        }
    }